Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ES7 stores #3

Merged
merged 3 commits into from
May 17, 2015
Merged

ES7 stores #3

merged 3 commits into from
May 17, 2015

Conversation

jhollingworth
Copy link
Contributor

@Handles

Support for @handles decorator instead of Store#handlers (Requires 'es7.decorators' enabled with babel)

let { handles } = require('marty');

class UserStore extends Marty.Store {
  @handles("RECIEVE_USER", "CREATE_USER")
  recieveUser(user) {
    ...
  }
}

Static handlers

You can define handlers on the static or as a class property (Requires 'es7.classProperties' enabled with babel)

class UserStore extends Marty.Store {
  static handlers = {
    receiveUser: ["RECEIVE_USER", "CREATE_USER"]
  }

  receiveUser(user) {
    ...
  }
}

UserStore.handlers = {
  receiveUser: ["RECEIVE_USER", "CREATE_USER"]
};

Resolves martyjs/marty#262

jhollingworth added a commit that referenced this pull request May 17, 2015
@jhollingworth jhollingworth merged commit a49c4de into master May 17, 2015
@jhollingworth jhollingworth deleted the es7-store branch May 17, 2015 11:57
let constants = toArray(arguments);

return function (target, name, descriptor) {
target.handlers = extend({}, target.handlers, {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool - no need to muck with hasOwnProperty or whatever in this case like for Application#register!

At some point later on it might be possible to use this to hide the handler, though it'd require changing how Store#handlers looks.

@dariocravero
Copy link
Contributor

I think this is a great addon :). I wonder if going forward we could even reduce the external API surface and have those methods removed/not accessible from the store's instance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Should Store.handlers be static?
3 participants